﻿app.controller('FormController', ['$scope', '$location', 'FormbyService', function ($scope, $location, FormbyService) {
    alert("++");

    var formID = 1;

    var reg = new RegExp("(^|\\?|&)FormID=([^&]*)(\\s|&|$)", "i");

    if (reg.test(location.href))

        formID = unescape(RegExp.$2.replace(/\+/g, " "));

    var postData = {
        FormID: formID
    }
    alert(formID);
    FormbyService.Formby(postData)
.success(function (resp) {


    var zt = {
        bs: '',
        data: [],
        mes: ''
    };

    var zt = resp;


    //zt = resp;
    $scope.items = zt.data;
    //alert(zt.bs)
    if (parseInt(zt.bs) > 0) {
    }
    else {
        $scope.items = [
       {
           Call: "",
           ConText: "似乎出错了.....",
           LogTime: "",
           Name: "",
           OperaType: "",
           PreTime: "",
           Tip: "",
       },
        ];
    }
})
.error(function (resp) { console.log(resp) });






















    //var zt = {
    //    bs: '',
    //    data: [],
    //    mes: ''
    //};

    //var zt = resp;


    ////zt = resp;
    //$scope.items = zt.data;
    ////alert(zt.bs)
    //if (parseInt(zt.bs) > 0) {
    //    alert("2");
    //}
    //else {
    //    alert("1");
    //    $scope.items = [
    //   {
    //       Call: "",
    //       ConText: "似乎出错了.....",
    //       LogTime: "",
    //       Name: "",
    //       OperaType: "",
    //       PreTime: "",
    //       Tip: "",
    //   },
    //    ];
    //}

}]);


app.factory('FormbyService', ['$http', function ($http) {
    var Formby = function (postData) {
        return $http.post('/Form/Formby', postData);
    }
    return {
        Formby: function (postData) { return Formby(postData); }
    }
}]);

